/*----------------------上传图片----------------------*/
function upImg(input){
	var files = input.files;
	var reader = new FileReader();
	var img = document.createElement('img');
	img.className = 'imgAppend';
	var divWrap = document.createElement('div');
	divWrap.className = 'imgAppendWrap';
	var imgDelete = document.createElement('img');
	imgDelete.src = $('#rechargeDeleteImg').val();
	imgDelete.className='rechargeDeleteImg';
	img.file = files[0];
	reader.onload = (function(aImg) {
      return function(e) {
        aImg.src = e.target.result;
      };
    })(img);
    reader.readAsDataURL(files[0]);
    divWrap.appendChild(img);
    divWrap.appendChild(imgDelete);
    $(input).parent().parent().get(0).appendChild(divWrap);
    addBtn();
}
//添加增加图片的按钮
function addBtn(){
	var str = '<div class="imgFileWrap"><div class="imgUpWrap"><input name="transferVoucher" type="file" class="upImg" accept="image/*" onchange="upImg(this)"/><div class="upImgBg">';
		str +='<img src="'+$('#addImg').val()+'" alt="" /><p>资料图片</p></div></div></div>';
	$('.imgInputWrap').append(str);
}

//删除图片
$(document).on('touchstart','.rechargeDeleteImg',function(){
	$(this).parent().parent().remove();
})
